<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>回调地址</title>
    <script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>
    <script src="plugins/axios/dist/axios.js"></script>
    <script src="plugins/vue/dist/vue.js"></script>
    <script src="js/common.js"></script>
</head>
<body>
<div id="myDiv">

</div>
<script type="text/javascript">
    new Vue({
        el:"#myDiv",
        data:{},
        methods: {},
        mounted(){
            // 解析url，拿到微信传给我的授权code
            let urlobj =str2Obj(location.href)
            // 调用后端接口，通过授权code,获取微信的accessToken和用户的openid
            let requestobj = {code :urlobj.code}
            this.$http.post("/wxuser/login",requestobj)
                .then(result=>{
                    result=result.data;
                    if (result.success){
                        // 说明后端已经绑定，登录成功，并且已经做了免密登录
                        let {token,logininfo}=result.result
                        //存进localStorage
                        localStorage.setItem("token",token)
                        localStorage.setItem("logininfo",JSON.stringify(logininfo))
                        location.href="/index.html"
                    }
                    if(!result.success && result.message == "toBind"){
                        let {accessToken,openid} = result.result;
                        console.log(accessToken,openid)
                        location.href = "/binder.html?accessToken="+accessToken+"&openid="+openid;
                    }
                }).catch(result=>{
            })
        }
    })

</script>


</body>
</html>